<?php

use yii\grid\GridView;
use common\helpers\Html;
use common\helpers\Url;
use common\helpers\ImageHelper;
use common\models\bonus\Bonus;
use yii\widgets\ActiveForm;
use kartik\daterange\DateRangePicker;
$this->title = '奖金列表';
$this->params['breadcrumbs'][] = ['label' => $this->title];

$addon = <<< HTML
<span class="input-group-addon">
    <i class="glyphicon glyphicon-calendar"></i>
</span>
HTML;
?>

<div class="row">
    <div class="col-xs-12">
        <div class="box">
                <br/>
                <br/>
                    <div class="col-sm-12">
                        <?php $form = ActiveForm::begin([
                            'method' => 'get',
                        ]); ?>
                        <div class="col-sm-8">
                            <div class="input-group drp-container col-lg-3 pull-left" style="margin-top: -5px;margin-left: 10px">
                                    <?= DateRangePicker::widget([
                                        'name' => 'queryDate',
                                        'value' => $start_time . '-' . $end_time,
                                        'readonly' => 'readonly',
                                        'useWithAddon' => true,
                                        'convertFormat' => true,
                                        'startAttribute' =>'start_time',
                                        'endAttribute' => 'end_time',
                                        'startInputOptions' => ['value' => $start_time],
                                        'endInputOptions' => ['value' => $end_time],
                                        'pluginOptions' => [
                                            'locale' => ['format' => 'Y-m-d'],
                                        ]
                                    ]) . $addon;?>
                                </div>
                        </div>
                    </div>
                <br/>
                <br/>
                <div class="form-group">
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input  type="submit" class="btn btn-primary btn-sm" value="搜索"  style="margin-top: 3px;">
                </div>
            <?php ActiveForm::end(); ?>

            <!-- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?= Html::tag('button','批量导出订单', ['class' => 'btn btn-info btn-sm  export']) ?> -->

                <br/>
            <div class="box-body table-responsive">

                <?= GridView::widget([
                    'dataProvider' => $dataProvider,
                    'filterModel' => $searchModel,
                    //重新定义分页样式
                    'tableOptions' => ['class' => 'table table-hover rf-table'],
                    'columns' => [
                        [
                            'class' => 'yii\grid\SerialColumn',
                            'visible' => false, // 不显示#
                        ],
                        [
                            'attribute' => 'id',
                            'headerOptions' => ['class' => 'col-md-1'],
                        ],
                        // [
                            
                        //     'attribute' => 'member_id',
                        //     'value'=>function($model){
                        //         return $model->member->username;
                        //     },
                        //     'filter' => false, //不显示搜索框

                        // ],
                         [
                            'attribute' => 'member.username',
                            'label'=> '会员编号',
                            'filter' => Html::activeTextInput($searchModel, 'member.username', [
                                    'class' => 'form-control'
                                ]
                            ),
                        ],
                        // [
                            
                        //     'header' => '真实姓名',
                        //     'value'=>function($model){
                        //         return $model->member->realname;
                        //     },
                        //     'filter' => false, //不显示搜索框

                        // ],
                        [
                            'attribute' => 'member.realname',
                            'label'=> '真实姓名',
                            'filter' => Html::activeTextInput($searchModel, 'member.realname', [
                                    'class' => 'form-control'
                                ]
                            ),
                        ],
                        [
                            'attribute' => 'bonus_type',
                            'filter' => Bonus::$typeArr,
                            'value' => function ($model)
                            {
                                return Bonus::$typeArr[$model->bonus_type];
                            },
                            'headerOptions' => ['class' => 'col-md-2'],
                        ],
                        [
                            'attribute' => 'amount',
                            'filter' => false, //不显示搜索框
                        ],
                        [
                            'attribute' => 'payment',
                            'filter' => false, //不显示搜索框
                        ],
                        [
                            
                            'attribute' => 'from_member_id',
                            'value'=>function($model){
                                return $model->fromMember->username;
                            },
                            'filter' => false, //不显示搜索框

                        ],
                        [
                            'attribute' => 'created_at',
                            'filter' => false, //不显示搜索框
                            'format' => ['date', 'php:Y-m-d H:i:s'],
                        ],
                        [
                            'attribute' => 'status',
                            'filter' => Bonus::$statusArr,
                            'value' => function ($model)
                            {
                                return Bonus::$statusArr[$model->status];
                            },
                            'headerOptions' => ['class' => 'col-md-2'],
                        ],
                        [
                            'attribute' => 'pay_at',
                            'filter' => false, //不显示搜索框
                            'format' => ['date', 'php:Y-m-d H:i:s'],
                        ],
                    ],
                ]); ?>
            </div>
        </div>
    </div>
<script type="text/javascript">
         //导出订单
    $(".export").on("click", function () {

       
        // var start_time = $('#w1-start').val();
        // var end_time =  $('#w1-end').val();
        var str = '';
        if (window.location.search.substring(1)) {
            str = window.location.search.substring(1);
        }
        // window.open("order-export?id="+keys+"&status="+status+"&start_time="+start_time+"&end_time="+end_time);
        window.open("order-export?"+str);

    });
</script>